import Vue from 'vue'
import Router from 'vue-router'
import Msite from '../pages/Msite/Msite.vue'
import Category from '../pages/Category/Category.vue'
import ShopCart from '../pages/ShopCart/ShopCart.vue'
import Profile from '../pages/Profile/Profile.vue'
import AddressList from '../components/AddressList/AddressList.vue'
import modiAddress from '../components/ModiAddress/ModiAddress.vue'
import ConfirmAddress from '../components/ConfirmAddress/ConfirmAddress.vue'
import AddAddress from '../components/AddAddress/AddAddress.vue'
import PaySuccess from '../components/PaySuccess/PaySuccess.vue'
import PayFail from '../components/PayFail/PayFail.vue'
import MyInvitation from '../components/MyInvitation/MyInvitation.vue'
import Login from '../pages/Login/Login.vue'
import Signup from '../pages/Signup/Signup.vue'
import GoodsList from '../components/GoodsList/GoodsList.vue'
import Lower from '../components/Lower/Lower.vue'
import UnderLower from '../components/UnderLower/UnderLower.vue'
import GoodsDetail from '../components/GoodsDetail/GoodsDetail'
import Partner from '../components/Partner/Partner'
import Collect from '../components/Collect/Collect.vue'
import FXOrder from '../components/FXOrder/FXOrder.vue'
import FXOrderDetail from '../components/FXOrderDetail/FXOrderDetail.vue'
import Coupon from '../components/Coupon/Coupon.vue'
import MyOrder from '../components/MyOrder/MyOrder.vue'
import WaitRefund from '../components/WaitRefund/WaitRefund.vue'
import WaitPay from '../components/WaitPay/WaitPay.vue'
import WaitReceive from '../components/WaitReceive/WaitReceive.vue'
import WaitEvaluate from '../components/WaitEvaluate/WaitEvaluate.vue'
import WaitDeliver from '../components/WaitDeliver/WaitDeliver.vue'
import Evaluate from '../components/Evaluate/Evaluate.vue'
import ApplyRefund from '../components/ApplyRefund/ApplyRefund.vue'
import ForgetPwd from '../components/ForgetPwd/ForgetPwd.vue'
import Advice from '../components/Advice/Advice.vue'
import ModiInfo from '../components/ModiInfo/ModiInfo.vue'
import ModiPwd from '../components/ModiPwd/ModiPwd.vue'
import BindPhoneNum from '../components/BindPhoneNum/BindPhoneNum.vue'
import ModiPhoneNum from '../components/ModiPhoneNum/ModiPhoneNum.vue'
import Message from '../components/Message/Message.vue'
import ConfirmPay from '../components/ConfirmPay/ConfirmPay.vue'
import ConfirmOrder from '../components/ConfirmOrder/ConfirmOrder.vue'
import OrderSuccess from '../components/OrderSuccess/OrderSuccess.vue'
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect:'/msite',
      meta:{
        // isNeedLogin 区分各个路由是否需要登录
        isNeedLogin:false,
        title:'珍馐坊'
      }
    },
    {
      path: '/msite',
      component: Msite,
      meta:{
        showFooter:true,
        isNeedLogin:false,
        title:'珍馐坊'
      }
    },
    {
      path: '/category',
      component: Category,
      meta:{
        showFooter:true,
        isNeedLogin:false,
        title:'分类'
      }
    },
    {
      path: '/shopcart',
      component: ShopCart,
      meta:{
        showFooter:true,
        isNeedLogin:false,
        title:'购物车',
        isShopCart:true
      }
    },
    {
      path: '/profile',
      component: Profile,
      meta:{
        showFooter:true,
        isNeedLogin:false,
        title:'个人中心'
      },
      // children:[
      //   {
      //     path:'/profile/myorder',
      //     component:MyOrder
      //   }
      // ]
    },
    // 我的订单
    {
      path:'/myorder',
      component:MyOrder,
      meta:{
        isNeedLogin:true,
        title:'我的订单'
      }
    },
    // 我的消息
    {
      path:'/message',
      component:Message,
      meta:{
        isNeedLogin:true,
        title:'我的消息'
      }
    },
    // 优惠券
    {
      path:'/coupon',
      component:Coupon,
      meta:{
        isNeedLogin:true,
        title:'我的优惠券'
      }
    },
    // 产品收藏
    {
      path:'/collect',
      component:Collect,
      meta:{
        isNeedLogin:true,
        title:'产品收藏'
      }
    },
    // 收货地址
    {
      path:'/addresslist',
      name: 'addresslist',
      component:AddressList,
      meta:{
        isNeedLogin:true,
        title:'收货地址'
      }
    },
    // 合伙人中心
    {
      path:'/partner',
      component:Partner,
      meta:{
        isNeedLogin:true,
        title:'合伙人中心'
      }
    },
    // 我的邀请
    {
      path:'/myinvitation',
      component:MyInvitation,
      meta:{
        isNeedLogin:true,
        title:'我的邀请'
      }
    },
    


    
    // 确认地址
    {
      path:'/confirmaddress',
      component:ConfirmAddress,
      meta:{
        isNeedLogin:true,
        title:'确认地址'
      }
    },
    // 新增地址
    {
      path:'/addaddress',
      component:AddAddress,
      meta:{
        isNeedLogin:true,
        title:'新增地址'
      }
    },
    // 修改地址
    {
      path:'/modiaddress',
      component:modiAddress,
      meta:{
        isNeedLogin:true,
        title:'修改地址'
      }
    },
    // 修改手机号
    {
      path:'/modiphonenum',
      component:ModiPhoneNum,
      meta:{
        isNeedLogin:true,
        title:'修改手机号'
      }
    },
    // 修改密码
    {
      path:'/modipwd',
      component:ModiPwd,
      meta:{
        isNeedLogin:true,
        title:'修改密码'
      }
    },
    // 意见反馈
    {
      path:'/advice',
      component:Advice,
      meta:{
        isNeedLogin:true,
        title:'意见反馈'
      }
    },







    // 支付成功
    {
      path:'/paysuccess',
      component:PaySuccess,
      meta:{
        isNeedLogin:true,
        title:'支付成功'
      }
    },
    // 支付失败
    {
      path:'/payfail',
      component:PayFail,
      meta:{
        isNeedLogin:true,
        title:'支付失败'
      }
    },
    
    // 注册
    {
      path:'/login',
      component:Login,
      meta:{
        isNeedLogin:false,
        title:'珍馐坊'
      }
    },
    // 登录
    {
      path:'/signup',
      component:Signup,
      meta:{
        isNeedLogin:false,
        title:'注册'
      }
    },
    // 商品列表
    {
      path:'/goodslist',
      component:GoodsList,
      meta:{
        isNeedLogin:false,
        title:'珍馐坊'
      }
    },
    // 我的下级
    {
      path:'/lower',
      component:Lower,
      meta:{
        isNeedLogin:true,
        title:'我的下级'
      }
    },
    // 我的下下级
    {
      path:'/underlower',
      component:UnderLower,
      meta:{
        isNeedLogin:true,
        title:'我的下下级'
      }
    },
    //  商品详情 
    {
      path:'/goodsdetail',
      component:GoodsDetail,
      meta:{
        isNeedLogin:false,
        title:'商品详情'
      }
    },
    // 分销订单
    {
      path:'/fxorder',
      component:FXOrder,
      meta:{
        isNeedLogin:true,
        title:'分销订单'
      }
    },
    // 分销订单详情
    {
      path:'/fxorderdetail',
      component:FXOrderDetail,
      meta:{
        isNeedLogin:true,
        title:'订单详情'
      }
    },
    // 待退款
    {
      path:'/waitrefund',
      component:WaitRefund,
      meta:{
        isNeedLogin:true,
        title:'待退款'
      }
    },
    // 待付款
    {
      path:'/waitpay',
      component:WaitPay,
      meta:{
        isNeedLogin:true,
        title:'退款'
      }
    },
    // 待收货
    {
      path:'/waitreceive',
      component:WaitReceive,
      meta:{
        isNeedLogin:true,
        title:'待收货'
      }
    },
    // 待评价
    {
      path:'/waitevaluate',
      component:WaitEvaluate,
      meta:{
        isNeedLogin:true,
        title:'待评价'
      }
    },
    // 待发货
    {
      path:'/waitdeliver',
      component:WaitDeliver,
      meta:{
        isNeedLogin:true,
        title:'待发货'
      }
    },
    // 发表评价
    {
      path:'/evaluate',
      component:Evaluate,
      meta:{
        isNeedLogin:true,
        title:'发布评价'
      }
    },
    // 申请退款
    {
      path:'/applyrefund',
      component:ApplyRefund,
      meta:{
        isNeedLogin:true,
        title:'申请退款'
      }
    },
    // 忘记密码
    {
      path:'/forgetpwd',
      component:ForgetPwd,
      meta:{
        isNeedLogin:true,
        title:'忘记密码'
      }
    },
    
    // 修改信息
    {
      path:'/modiinfo',
      component:ModiInfo,
      meta:{
        isNeedLogin:true,
        title:'修改信息'
      }
    },
     
     // 绑定手机号
     {
      path:'/bindphonenum',
      component:BindPhoneNum,
      meta:{
        isNeedLogin:true,
        title:'绑定手机号'
      }
    },
    
    
    // 确认支付
    {
     path:'/confirmpay',
     name: 'confirmpay',
     component:ConfirmPay,
     meta:{
      isNeedLogin:true,
      title:'确认支付'
      }
    },
    // 确认订单
    {
      path:'/confirmorder',
      name: 'confirmorder',
      component:ConfirmOrder,
      meta:{
        isNeedLogin:true,
        title:'确认订单'
      }
     },
     // 确认订单
    {
      path:'/ordersuccess',
      name: 'ordersuccess',
      component:OrderSuccess,
      meta:{
        isNeedLogin:true,
        title:'订单'
      }
    }
  ],
  
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})
